<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/catalog"%>
<%@ taglib prefix="prod" tagdir="/WEB-INF/tags/product"%>
<probiz:pageHeading pageHeadingKey="associateBulkEdit.heading" />
<content tag="buttons">
<probiz:iconBtn btnType="save" onclick="associatedBulkEditSave();" />
<probiz:iconBtn btnType="back" url="${ctxPath}/product/prod.html" />
</content>
<form method="post" id="productForm" name="productForm"
	action="${ctxPath}/product/prod.html">
	<c:forEach items="${productList}" var="product" varStatus="status">
		<input type="hidden" name="productIds" id="productIds"
			value="${product.productId}" />
	</c:forEach>

	<table class="com_modi_table" width="100%">
		<c:forEach items="${productList}" var="product" varStatus="status">
			<tr>
				<th colspan="2" class="title">
					<h4>${product.productName}(${product.productCode})</h4>
				</th>
			</tr>
			<tr>
				<td>
					<div class="p_sku">
						<div class="content" id="skuTable${product.productId}">

							<c:forEach items="${product.productSkus}" var="sku">
								<div id="sku_${sku.productSkuId }" class="content">
									<div class="circle_corner_block1">
										<div class="circle_corner_block2">
											<div class="circle_corner_block3">
												<div class="cnt">
													<div class="do"></div>
													<table class="sku_table_wrap">
														<tbody>
															<tr>
																<td valign="top" class="multiSku" <c:if test="${(empty product.isSetMultiSkus) or (product.isSetMultiSkus == 0) }">style="display: none;"</c:if>>
																	<table class="sku_table">
																		<tbody>
																			<tr>
																				<td valign="top">
																					<div class="sku">
																						<ul class="now"></ul>
																					</div>
																				</td>
																				<td valign="top">
																					<div class="img_wrap">
																						<a target="_blank" href="${mediaPath }/<prod:imageSrc url="${not empty sku.imageUrl?sku.imageUrl:sku.product.imageUrl}" sizeType="s2" />">
																						<img src="${mediaPath }/<prod:imageSrc url="${not empty sku.imageUrl?sku.imageUrl:sku.product.imageUrl}" sizeType="s1" />" height="120" width="115" onerror="this.src=__defaultImage;this.onerror=''"/>
																						</a>
																					</div>
																				</td>
																			</tr>
																		</tbody>
																	</table>
																</td>
																<td valign="top">
																	<ul style="width: 450px;"
																		id="accordion_${sku.productSkuId }"
																		class="ui-accordion">
																		<li class=""
																			onclick="$j('#wholesalePriceDivId_${sku.productSkuId }').hide();
																				$j('#accordion_table_${sku.productSkuId }').show();">

																			<span class="ui-accordion-left"></span>
																			<h3 class="ui-accordion-header" tabindex="0">
																			<fmt:message key="associatedBulk.basicSaleMessage"/>
																				<span class="ui-accordion-right"></span>
																			</h3>
																			<table class="normal_table1" style="height: 147px;"
																				id="accordion_table_${sku.productSkuId }">
																				<tbody>
																					<tr>
																						<th>
																							<fmt:message key="associatedBulk.marketPrice"/>
																						</th>
																						<td>
																							<input type="text" style="width: 120px;"
																								class="inputtxt" value="${sku.listPrice }"
																								name="listPrices"
																								id="listPrice_${sku.productSkuId }">
																						</td>
																						<th>
																						<fmt:message key="associatedBulk.goodsNumber"/>
																						</th>
																						<td>
																							${sku.productSkuCode }
																						</td>
																					</tr>
																					<tr>
																						<th>
																							<fmt:message key="associatedBulk.nowSalePrice"/>(
																							<span class="red">*</span>):
																						</th>
																						<td>
																							<input type="text" style="width: 120px;"
																								class="inputtxt" value="${sku.price }"
																								name="prices" id="price_${sku.productSkuId }">
																						</td>
																						<th>
																						<fmt:message key="associatedBulk.inventory"/>
																						</th>
																						<td>
																							<input type="text" style="width: 120px;"
																								class="inputtxt"
																								value="${sku.inventory.quantityOnHand }"
																								name="inventorys"
																								id="inventory_${sku.productSkuId }">
																						</td>
																					</tr>
																					<tr>
																						<th>
																							<fmt:message key="associatedBulk.specialPrice"/>
																						</th>
																						<td>
																							<input type="text" style="width: 120px;"
																								class="inputtxt" value="${sku.salePrice }"
																								name="salePrices"
																								id="salePrice_${sku.productSkuId }">
																						</td>
																						<th>
																						<fmt:message key="associatedBulk.goodsWeight"/>
																						</th>
																						<td>
																							<input type="text" style="width: 120px;"
																								class="inputtxt" value="${sku.weight }"
																								name="weights" id="weight_${sku.productSkuId }">
																							(${appConfig.weightUnit})
																						</td>
																					</tr>
																				</tbody>
																			</table>
																		</li>
																		<li
																			onclick="$j('#wholesalePriceDivId_${sku.productSkuId }').show();
																			$j('#accordion_table_${sku.productSkuId }').hide();">
																			<span class="ui-accordion-left"></span>
																			<h3 class="ui-accordion-header selected" tabindex="0">
																			<fmt:message key="associatedBulk.tradePrice"/>
																				<span class="ui-accordion-right"></span>
																			</h3>
																			<div style="height: 147px; display: none;"
																				class="list_price"
																				id="wholesalePriceDivId_${sku.productSkuId }">
																				<table class="normal_table2">
																					<tbody>
																						<tr>
																							<th>
																								<fmt:message key="associatedBulk.quantity"/>
																							</th>
																							<th>
																							<fmt:message key="associatedBulk.maxQuantity"/>
																							</th>
																							<th>
																								<fmt:message key="associatedBulk.nowSalePrice"/>
																							</th>
																							<th>
																							<fmt:message key="associatedBulk.deleted"/>
																							</th>
																						</tr>
																					</tbody>
																				</table>
																				<div class="price_wrap">
																					<table
																						id="wholesalePriceTable_${sku.productSkuId }"
																						class="normal_table3">
																						<c:forEach items="${sku.wholesalePrices}" var="wp" varStatus="wpStatus">
																							<tr id="wholesalePrice_${wp.wholesalePriceId }">
																								<td>
																									<c:choose>
																										<c:when test="${wpStatus.count!=1 }">
																											<input onchange="wpMinQuantityHandler('_${wp.wholesalePriceId }')"
																												value="${empty wp.minQuantity?1:wp.minQuantity }" name="wpMinQuantitys"
																												id="wpMinQuantity_${wp.wholesalePriceId }"
																												class="minQuantity inputtxt"
																												style="width: 100px;" type="hidden"/>
																												${empty wp.minQuantity?1:wp.minQuantity }
																										</c:when>
																										<c:otherwise>
																											<input onchange="wpMinQuantityHandler('_${wp.wholesalePriceId }')"
																												value="${empty wp.minQuantity?1:wp.minQuantity }" name="wpMinQuantitys"
																												id="wpMinQuantity_${wp.wholesalePriceId }"
																												class="minQuantity inputtxt"
																												style="width: 100px;">
																										</c:otherwise>
																									</c:choose>
																								</td>
																								<td>
																									<input onchange="wpMaxQuantityHandler('_${wp.wholesalePriceId }')"
																										value="${wp.maxQuantity }" name="wpMaxQuantitys"
																										id="wpMaxQuantity_${wp.wholesalePriceId }"
																										class="maxQuantity inputtxt"
																										style="width: 100px;">
																								</td>
																								<td>
																									<input value="${wp.price }" name="wpPrices"
																										id="wpPrice_${wp.wholesalePriceId }" class="inputtxt"
																										style="width: 100px;">
																								</td>
																								<td>
																									<a
																										onclick="delWholesalePrice('wholesalePriceTable_${sku.productSkuId }','wholesalePrice_${wp.wholesalePriceId }')"
																										href="javascript:void(0)"
																										class="deleteWholesalePrice del_price"
																										<c:if test="${!wpStatus.last }">style="display: none;"></c:if><b>&nbsp;</b>
																									</a>
																								</td>
																								<input type="hidden" value="wpId_${wp.wholesalePriceId }" id="wpId_${wp.wholesalePriceId }"
																									name="wpIds">
																								<input type="hidden" value="wpskuId_${sku.productSkuId }"
																									id="wpskuId_${sku.productSkuId }" name="wpSkuIds">
																							</tr>
																						</c:forEach>
																					</table>
																				</div>
																				<div class="add_wrap">
																					<a
																						onclick="addWholesalePrice('wholesalePriceTable_${sku.productSkuId }',null)"
																						href="javascript:void(0)" class="add_price"></a>
																				</div>
																			</div>
																		</li>
																	</ul>
																</td>
															</tr>
														</tbody>
													</table>
												</div>
											</div>
										</div>
									</div>
									<input type="hidden" id="skuId_${sku.productSkuId }"
										value="skuId_${sku.productSkuId }" name="skuIds">
								</div>
							</c:forEach>

						</div>
					</div>
				</td>
			</tr>
		</c:forEach>
	</table>
</form>

<v:javascript formName="product" staticJavascript="false" />
<c:set var="ui_accordion" value="true" scope="request" />
<script type="text/javascript"
	src="${ctxPath}/scripts/probiz/product/associatedBulkEditForm.js?rs=${appConfig.rs}"></script>
<script type="text/javascript">
$j(document).ready(function () {
	__FMTExtend = {
		productForm_signNotNegativeNum:"<fmt:message key="productForm.signNotNegativeNum"/>",
		productForm_signLastMaxQuantity:"<fmt:message key="productForm.signLastMaxQuantity"/>",
		productForm_basicPrice:"<fmt:message key="productForm.basicPrice"/>",
		productForm_wholesalePrice:"<fmt:message key="productForm.wholesalePrice"/>",
		productForm_promotionPrice:"<fmt:message key="productForm.promotionPrice"/>",
		productForm_incorrectMaxQuantity:"<fmt:message key="productForm.incorrectMaxQuantity"/>",
		
		productSku_listPrice:"<fmt:message key="productSku.listPrice"/>",
		productSku_price:"<fmt:message key="productSku.price"/>",
		productSku_salePrice:"<fmt:message key="productSku.salePrice"/>",
		productSku_weight:"<fmt:message key="productSku.weight"/>",
		productSku_inventory:"<fmt:message key="productSku.inventory"/>",
		productSku_image_tip:"<fmt:message key="productSku.image.tip"/>",
		productSku_productSkuCode:"<fmt:message key="productSku.productSkuCode"/>",
		
		wholesalePrice_price:"<fmt:message key="wholesalePrice.price"/>",
		wholesalePrice_minQuantity:"<fmt:message key="wholesalePrice.minQuantity"/>",
		wholesalePrice_maxQuantity:"<fmt:message key="wholesalePrice.maxQuantity"/>",
		wholesalePrice_delete:"<fmt:message key="wholesalePrice.delete"/>",
		associateBulkEdit_commit_success:"<fmt:message key="associateBulkEdit.commit.success"/>"
	};
	$j.extend(__FMT, __FMTExtend); 
});	

$j(document).ready(function () {
	<%--start:初始化sku
	<c:forEach items="${productList}" var="product" varStatus="status">
		<c:choose>
			<c:when test="${fn:length(product.productSkus) == 0}">
				//var wholesalePriceTableId = addSku("skuTable${product.productId}",null);
				changeToSingleSku("skuTable${product.productId}");
				closeSkuOptions();
			</c:when>
			<c:otherwise>
				<c:forEach items="${product.productSkus}" var="sku">
					//var wholesalePriceTableId = addSku("skuTable${product.productId}",{id:${sku.productSkuId},code:"${sku.productSkuCode}",imageUrl:"${sku.imageUrl}",listPrice:"${sku.listPrice}",price:"${sku.price}",salePrice:"${sku.salePrice}",weight:"${sku.weight}",inventory:"${sku.inventory.quantityOnHand}",optionValueInfo:"${sku.skuOptionValueInfo}",skuOptionInfoJson:eval(${sku.skuOptionInfoJson})});
					<c:forEach items="${sku.wholesalePrices}" var="wp" varStatus="wpStatus">
						addWholesalePrice(wholesalePriceTableId,{wpId:${wp.wholesalePriceId},wpSkuId:${wp.productSkuId},wpMinQuantity:"${wp.minQuantity}",wpMaxQuantity:"${wp.maxQuantity}",wpPrice:"${wp.price}",wpDeliveryDay:""},${wpStatus.index == 0});
					</c:forEach>
				</c:forEach>
				<c:choose>
					<c:when test="${(empty product.isSetMultiSkus) or (product.isSetMultiSkus == 0)}">
						changeToSingleSku("skuTable${product.productId}");
					</c:when>
					<c:otherwise>
						changeToMultiSkus("skuTable${product.productId}");	
					</c:otherwise>
				</c:choose>
			</c:otherwise>
		</c:choose>	
	</c:forEach>--%>
	<%--end:初始化sku--%>
});	

</script>
